home *** CD-ROM | disk | FTP | other *** search
/ The Best of Down Under Games / The Best of Down Under Games.iso / 3dfx Screen Savers / VoodooLights / Sources / cell_tp1.c < prev    next >
C/C++ Source or Header  |  1997-07-23  |  2KB  |  96 lines

  1. /*------------------------------------------------------/
  2. /                                                        /
  3. /    Copyright 1997, SΘrgio Durte <smd@di.fct.unl.pt>    /
  4. /                                                        /
  5. /------------------------------------------------------*/
  6.  
  7.  
  8. #include <stdlib.h>
  9. #include <glide.h>
  10.  
  11. #include "defines.h"
  12. #include "mat.h"
  13. #include "rgb.h"
  14. #include "cell.h"
  15. #include "cell_util.h"
  16. #include "cell_tp1.h"
  17. #include "cell_tp2.h"
  18. #include "cell_tp4.h"
  19.  
  20. static Bool first_init = True ;
  21. static GrMipMapId_t tp1_texture_src ;
  22.  
  23. void tp1_set_glide_state( void )
  24. {
  25.     if( first_init ) {
  26.         first_init = False ;
  27.         tp1_texture_src = tex_InitTexture("flare2.3df") ;
  28.     }    
  29.     tex_SetTexSource( tp1_texture_src ) ;
  30.     grTexCombineFunction(GR_TMU0, GR_TEXTURECOMBINE_DECAL );
  31.     guColorCombineFunction( GR_COLORCOMBINE_TEXTURE_TIMES_ITRGB ) ;
  32.     guAlphaSource( GR_ALPHASOURCE_ITERATED_ALPHA );    
  33.     grAlphaBlendFunction( GR_BLEND_ONE, GR_BLEND_ONE, GR_BLEND_ONE, GR_BLEND_ZERO );
  34. }
  35.  
  36. static void tp1_acc_cell(Cell *c) 
  37. {
  38.   int n ;
  39.   Cell **p ;
  40.   
  41.   mat_scalev( -1.0, & c->pos, & c->acc ) ;
  42.  
  43.   p = cell_get_cells_by_type( CellType1, & n ) ;
  44.   cutl_closest_interaction( c, p, n, -10000.0, 1.0 ) ;
  45.  
  46.   p = cell_get_cells_by_type( CellType2, & n ) ;
  47.   cutl_closest_interaction( c, p, n, -35000.0, 2.0 ) ;
  48. }
  49.  
  50. static void tp1_reproduce_cell( Cell *c )
  51. {
  52.     if( rnd() <  c->p_chld ) ctp4_Constructor( c ) ;
  53. }
  54.  
  55. Cell *ctp1_Constructor( Cell *dad )
  56. {
  57.  
  58.   Cell *c = cell_Constructor( CellType1 ) ;
  59.  
  60.   c->max_speed = 100.0 ;
  61.  
  62.   c->dad = dad ;
  63.  
  64.   c->max_chld = 1 ;
  65.   c->p_chld = 0.8 ;
  66.   c->adulthood = 450.0 ;
  67.   c->size = 15.0 ;
  68.   c->size = 20.0 ;
  69.  
  70.   cutl_random_pos( 400.0, c ) ;
  71.  
  72.   c->sparkle = 0.9 ;
  73.   c->sparkle_range = 0.2 ;
  74.   c->sparkle_min = 0.6 ;
  75.  
  76.   c->color.r = 255.0 ;
  77.   c->color.g = 255.0 ;
  78.   c->color.b = 135.0 ;
  79.   c->color.a = 255.0 ;
  80.  
  81.   c->acc_cell = tp1_acc_cell ;
  82.   c->reproduce_cell = tp1_reproduce_cell ;
  83.  
  84.   return c ;
  85. }  
  86.     
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.     
  95.  
  96.